<?php

$xmld = <<<XML
<graph>
    <size width="500" height="500"/>
    <edges>
        <edge>
            <points>
                <point x="99" y="304"/>
                <point x="98" y="299"/>
                <point x="98" y="294"/>
                <point x="98" y="288"/>
                <point x="98" y="283"/>
                <point x="98" y="277"/>
                <point x="99" y="271"/>
                <point x="101" y="266"/>
                <point x="103" y="261"/>
                <point x="106" y="256"/>
                <point x="109" y="252"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="104" y="305"/>
                <point x="106" y="300"/>
                <point x="108" y="295"/>
                <point x="109" y="290"/>
                <point x="111" y="285"/>
                <point x="112" y="280"/>
                <point x="113" y="275"/>
                <point x="114" y="270"/>
                <point x="116" y="265"/>
                <point x="117" y="260"/>
                <point x="117" y="255"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="71" y="380"/>
                <point x="73" y="376"/>
                <point x="74" y="371"/>
                <point x="76" y="366"/>
                <point x="78" y="361"/>
                <point x="81" y="355"/>
                <point x="83" y="350"/>
                <point x="85" y="344"/>
                <point x="88" y="339"/>
                <point x="90" y="334"/>
                <point x="93" y="329"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="76" y="384"/>
                <point x="81" y="381"/>
                <point x="85" y="377"/>
                <point x="89" y="372"/>
                <point x="93" y="367"/>
                <point x="96" y="361"/>
                <point x="98" y="355"/>
                <point x="99" y="349"/>
                <point x="100" y="343"/>
                <point x="101" y="337"/>
                <point x="101" y="331"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="151" y="77"/>
                <point x="147" y="71"/>
                <point x="143" y="65"/>
                <point x="138" y="58"/>
                <point x="132" y="51"/>
                <point x="126" y="44"/>
                <point x="120" y="38"/>
                <point x="113" y="32"/>
                <point x="106" y="27"/>
                <point x="99" y="23"/>
                <point x="93" y="19"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="50" y="156"/>
                <point x="57" y="151"/>
                <point x="65" y="146"/>
                <point x="74" y="139"/>
                <point x="84" y="132"/>
                <point x="94" y="125"/>
                <point x="104" y="118"/>
                <point x="114" y="112"/>
                <point x="124" y="106"/>
                <point x="133" y="100"/>
                <point x="142" y="95"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="119" y="153"/>
                <point x="121" y="149"/>
                <point x="124" y="144"/>
                <point x="127" y="139"/>
                <point x="130" y="134"/>
                <point x="133" y="128"/>
                <point x="136" y="122"/>
                <point x="140" y="117"/>
                <point x="143" y="111"/>
                <point x="146" y="106"/>
                <point x="148" y="101"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="128" y="230"/>
                <point x="135" y="220"/>
                <point x="142" y="207"/>
                <point x="148" y="193"/>
                <point x="152" y="181"/>
                <point x="155" y="170"/>
                <point x="158" y="159"/>
                <point x="160" y="145"/>
                <point x="162" y="130"/>
                <point x="162" y="116"/>
                <point x="160" y="103"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="44" y="152"/>
                <point x="46" y="143"/>
                <point x="49" y="132"/>
                <point x="52" y="119"/>
                <point x="55" y="105"/>
                <point x="59" y="91"/>
                <point x="62" y="77"/>
                <point x="66" y="63"/>
                <point x="69" y="49"/>
                <point x="72" y="37"/>
                <point x="75" y="27"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="34" y="228"/>
                <point x="34" y="224"/>
                <point x="35" y="219"/>
                <point x="35" y="214"/>
                <point x="36" y="209"/>
                <point x="37" y="204"/>
                <point x="37" y="199"/>
                <point x="38" y="194"/>
                <point x="38" y="189"/>
                <point x="39" y="184"/>
                <point x="39" y="179"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="21" y="306"/>
                <point x="16" y="296"/>
                <point x="10" y="284"/>
                <point x="5" y="270"/>
                <point x="1" y="255"/>
                <point x="0" y="240"/>
                <point x="3" y="225"/>
                <point x="9" y="211"/>
                <point x="16" y="198"/>
                <point x="24" y="186"/>
                <point x="31" y="176"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="111" y="152"/>
                <point x="109" y="143"/>
                <point x="106" y="132"/>
                <point x="103" y="119"/>
                <point x="100" y="105"/>
                <point x="97" y="91"/>
                <point x="93" y="77"/>
                <point x="90" y="63"/>
                <point x="87" y="49"/>
                <point x="84" y="37"/>
                <point x="82" y="27"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="40" y="231"/>
                <point x="45" y="227"/>
                <point x="51" y="222"/>
                <point x="57" y="216"/>
                <point x="63" y="210"/>
                <point x="70" y="204"/>
                <point x="77" y="197"/>
                <point x="84" y="191"/>
                <point x="90" y="185"/>
                <point x="96" y="179"/>
                <point x="101" y="174"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="119" y="228"/>
                <point x="119" y="224"/>
                <point x="119" y="219"/>
                <point x="118" y="214"/>
                <point x="118" y="209"/>
                <point x="117" y="204"/>
                <point x="117" y="199"/>
                <point x="116" y="194"/>
                <point x="116" y="189"/>
                <point x="115" y="184"/>
                <point x="115" y="179"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="30" y="228"/>
                <point x="26" y="211"/>
                <point x="23" y="190"/>
                <point x="21" y="166"/>
                <point x="22" y="142"/>
                <point x="24" y="123"/>
                <point x="32" y="99"/>
                <point x="40" y="81"/>
                <point x="49" y="65"/>
                <point x="60" y="45"/>
                <point x="70" y="25"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="28" y="304"/>
                <point x="28" y="300"/>
                <point x="29" y="295"/>
                <point x="29" y="290"/>
                <point x="29" y="285"/>
                <point x="30" y="280"/>
                <point x="30" y="275"/>
                <point x="30" y="270"/>
                <point x="31" y="265"/>
                <point x="31" y="260"/>
                <point x="31" y="255"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="57" y="386"/>
                <point x="52" y="383"/>
                <point x="46" y="379"/>
                <point x="41" y="375"/>
                <point x="36" y="370"/>
                <point x="32" y="364"/>
                <point x="29" y="358"/>
                <point x="27" y="351"/>
                <point x="25" y="344"/>
                <point x="25" y="338"/>
                <point x="25" y="331"/>
            </points>
        </edge>
        <edge>
            <points>
                <point x="62" y="381"/>
                <point x="60" y="377"/>
                <point x="57" y="372"/>
                <point x="55" y="367"/>
                <point x="52" y="362"/>
                <point x="49" y="356"/>
                <point x="46" y="351"/>
                <point x="43" y="345"/>
                <point x="40" y="340"/>
                <point x="38" y="335"/>
                <point x="35" y="330"/>
            </points>
        </edge>
    </edges>
</graph>
XML;

$xmld1 = <<<XML
<graph>
    <size width="1200" height='500' />
    <vertices>
        <vertex x='100.372' y='315' />
        <vertex x='156.372' y='87' />
        <vertex x='41.3723' y='163' />
        <vertex x='113.372' y='163' />
        <vertex x='32.3723' y='239' />
        <vertex x='27.3723' y='315' />
        <vertex x='67.3723' y='391' />
        <vertex x='120.372' y='239' />
        <vertex x='78.3723 ' y='11' />
    </vertices>
    <edges>
        <edge>
            <label x='105.372' y='277' text='6' />
            <points>
                <pos x='98.5466' y='303.895' />
                <pos x='97.3762' y='294.191' />
                <pos x='96.6848' y='279.842' />
                <pos x='100.372' y='268' />
                <pos x='102.21' y='262.099' />
                <pos x='105.714' y='256.337' />
                <pos x='109.282' y='251.525' />
            </points>
        </edge>
    </edges>
</graph>
XML;

include_once 'GraphDrawer.php';
header("Content-type: image/png");

define(DATA, 'data');           // xml data with data about graph edges and vertices
define(BG_COLOR, 'bgcolor');
define(NORMAL_COLOR, 'ncolor'); // color of the graph in normal state
define(ACTIVE_COLOR, 'acolor'); // color of the active cycle in the graph
define(ACTIVE_CYCLE, 'ac');     // active cycle in the graph

//$gd = new GraphDrawer($_GET[DATA]);
$gd = new GraphDrawer($xmld);
$gd->setActiveCycle($_GET[ACTIVE_CYCLE]);
$gd->process();

//$textcolor = imagecolorallocate($gd->getImage(), 255, 255, 255);
//imagestring($gd->getImage(), 5, 0, 0, $xmld, $textcolor);
imagepng($gd->getImage());
?>
